<template>
  <div>
    <div class="center_dialog">
      <el-divider>基本信息</el-divider>
      <el-descriptions :colon="false" title="" direction="vertical" :column="5" border>
        <el-descriptions-item label="标题">{{ allocation.title || '-' }}</el-descriptions-item>
        <el-descriptions-item label="计划编号">{{ allocation.planNum || '-' }}</el-descriptions-item>
        <el-descriptions-item label="计划盘点时间">{{ allocation.startTime || '-' }}~{{ allocation.endTime || '-' }}
        </el-descriptions-item>
        <el-descriptions-item label="责任部门">{{ allocation.deptName || '-' }}</el-descriptions-item>
        <el-descriptions-item label="责任人">{{ allocation.headName || '-' }}</el-descriptions-item>
      </el-descriptions>
      <el-divider>盘点信息</el-divider>
      <el-table :data="gridData">
        <el-table-column prop="order" label="序号" width="50"></el-table-column>
        <el-table-column label="任务编号" width="160">
          <template slot-scope="{row}">
            <el-link @click="handledetailed(row)" type="primary">{{ row.taskNum || '-' }}</el-link>
          </template>
        </el-table-column>
        <el-table-column prop="stktakingDeptName" label="盘点范围" min-width="120"></el-table-column>
        <el-table-column prop="headName" label="任务责任人" min-width="120"></el-table-column>
        <el-table-column label="盘点方式" min-width="120">
          <template slot-scope="{row}">
            {{ ['全盘盘点', '比例盘点'][row.type] || '-' }}
          </template>
        </el-table-column>
        <el-table-column label="盘点比例" min-width="120">
          <template slot-scope="{row}">
            {{ row.type === '0' ? '-' : row.proportion * 100 + '%' || '0%' }}
          </template>
        </el-table-column>
        <el-table-column label="盘点对象生成方式" min-width="120">
          <template slot-scope="{row}">
            {{ ['随机生成', '手动生成'][row.generationType] || '-' }}
          </template>
        </el-table-column>
        <el-table-column label="任务状态" min-width="120">
          <template slot-scope="{row}">
            <dict-tag :options="statusPlan" :value="row.status" />
          </template>
        </el-table-column>
        <el-table-column label="应盘" min-width="120">
          <template slot-scope="{row}">
            {{ row.planCount || '0' }}
          </template>
        </el-table-column>
        <el-table-column label="已盘" min-width="120">
          <template slot-scope="{row}">
            {{ row.completeCount || '0' }}
          </template>
        </el-table-column>
        <el-table-column label="盘点结果" min-width="120">
          <template slot-scope="{row}">
            {{ row.status === '3' && row.planCount - row.completeCount || '-' }}
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { getChlidrenStktaking } from '@/api/Inventory/Inventory.js'
export default {
  props: ['rowObj'],
  data () {
    return {
      auditData: [],
      islength: true,
      allocation: {},
      gridData: []
    }
  },
  created () {
    this.getlist()
  },
  methods: {
    /**
     * 初始化
     */
    getlist () {
      getChlidrenStktaking(this.rowObj.planId).then(res => {//详情接口
        this.allocation = res.data
        this.gridData = res.data.stktakingTaskVoList && res.data.stktakingTaskVoList.map((item, index) => {
          return {
            ...item,
            order: index + 1
          }
        })
      }).catch(err => {
        console.log(err);
      })
    },
    handledetailed (row) {
      this.$emit('handleChildren', row)
    }
  }
}
</script>

<style lang="scss" scoped>
.center_dialog {
  // text-align: center;
  width: 100%;
  // padding: 0 10% 0 10%;
  box-sizing: border-box;
  // margin: 0px auto;
}
</style>